/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mamayukero.problem.environment.map;

import java.util.ArrayList;
import mamayukero.problem.environment.component.*;

public class Map {
    public Boolean[][] block;
    public int col, row, size;
    public Factory factory;
    public Truck truck;
    public ArrayList<Vendor> vendor;
    
    public Map() {
        factory = new Factory();
        vendor = new ArrayList<Vendor>();
        truck = new Truck();
    }
    
    public final void initBlock(int rownumber, int colnumber) {
        col = colnumber;
        row = rownumber;
        block = new Boolean[col][row];
        for (int i = 0; i < row;i++) {
            for (int j = 0; j < col;j++) {
                block[j][i] = true;
            }
        }
    }
    
    
    public final void initBlock(int rownumber, int colnumber, Matrix matrix) {
        col = colnumber;
        row = rownumber;
        block = new Boolean[col][row];
        for (int i = 0; i < row;i++) {
            for (int j = 0; j < col;j++) {
                block[j][i] = (matrix.at(i, j) != Const.UNMOVEABLE);
            }
        }
    }
    
    public boolean At(int x, int y) {
        return block[x][y];
    }
	
    public void setVendorsStraightLines()
	{
		for (Vendor v : vendor)
		{
			v.setStraightLine(factory);
		}
	}
	
    public void printMap()
    {
		for (Vendor v : vendor)
		{
				System.out.println(v.toString());	
		}
		System.out.println(factory.toString());
    }
}
